#ifndef HLPBLANK
#define HLPBLANK


#include "VMPFocus.hpp"
#include "operations.hpp"
//Helper Blank
//Formula:
//\n| |

//helper:

cText TEXT_BLANK="blank";
/*
void funHlpBlankPostL(ListIdentity* what){
	ptrOperation opb=Operations[TEXT_BLANK];
	int i=0;
	for (; i<lsOperations.length(); ++i)
		if (lsOperations[i]==opb)
			break;
	lsOperations.erase(lsOperations.begin()+i);
};
*/
//PreLining:

//PostLining:

void funHlpBlankPostL(ListIdentity* what){
	int i=0;
	//cList<cRange> rangeLs;
	//Exploit the f that Lining doesn't rearrange Identifiers list. when postL.
	int begin=-1,end=-1;
	ptrOperation opB=Operations[TEXT_BLANK];
	for (; i<what->length();){
		if ((*what)[i]->Operation==opB){
			if (begin<=(*what)[i]->Range.begin){
				if (end<(*what)[i]->Range.end){ //needs refreshing!
					begin=(*what)[i]->Range.begin;
					end=(*what)[i]->Range.end;
					if (begin==(*what)[i-1]->Range.begin &&
						(*what)[i-1]->Operation==opB){ //and remove!
						what->erase(what->begin()+i-1); //remove previous.
						--i;
					}else
						++i;
				}
				else{ //remove this: range.end<=end.
					what->erase(what->begin()+i);
					//--i;
				};
			};
		}else
			++i;
	};
	i=0;
	for (; i<lsOperations.length(); ++i)
		if (lsOperations[i]==opB)
			break;
	lsOperations.erase(lsOperations.begin()+i);
};

//MkTree:
ptrParsedElement funHlpBlankMkTree(ptrText code, ptrIdentity identity, ptrParsedElement PE){
	return 0;
};

//Evaluate:

ptrOperation loadHlpBlank(){
	ptrOperation tmp=new cOperation();
	tmp->Formula="( |\t|\n)+"; //quote needed.
	tmp->Name=TEXT_BLANK;
	tmp->onEvaluate=NULL;
	tmp->onPreLining=NULL;
	tmp->onPostLining=funHlpBlankPostL;
	tmp->onMakingTree=funHlpBlankMkTree;
	return tmp;
}


#endif